package cn.com.jinhao.provider.user.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * HotLine
 * <p>Description: 用户实体类</p>
 *
 * @author ShaneMew
 * @version 1.0
 * @date 2019/10/18
 * @since 2019-10-18
 */
@ToString
@Data
@Table(name = "ST$OPER")
@ApiModel(value = "User", description = "用户信息")
public class User extends Base implements Serializable {
    private static final long serialVersionUID = 1L;

    @Column(name = "oper")
    @ApiModelProperty(value = "用户名")
    @Length(max = 20, message = "用户名不能超过20个字符")
    @Pattern(regexp = "^[A-Za-z0-9]{4,15}$", message = "字母开头，长度在5-16字节，只能包含字母数字下划线")
    private String oper;

    @Column(name = "spel")
    @ApiModelProperty(value = "汉语拼音")
    @NotEmpty(message = "汉语拼音不能为空")
    private String spel;

    @Column(name = "pass")
    @ApiModelProperty(value = "密码")
    @NotEmpty(message = "密码不能为空")
    @Pattern(regexp = "^[a-zA-Z]\\w{5,17}$", message = "以字母开头，长度在6~18之间，只能包含字母、数字和下划线")
    private String pass;

    @Column(name = "name")
    @ApiModelProperty(value = "姓名")
    @NotEmpty(message = "姓名不能为空")
    @Length(max = 4)
    private String name;

    @Column(name = "sexu")
    @ApiModelProperty(value = "性别")
    private Short sex;

    @Column(name = "cpno")
    @ApiModelProperty(value = "移动电话")
    @Pattern(regexp = "^(13[0-9]|14[5|7]|15[0-3,5-9]|18[0-3,5-9])\\d{8}", message = "手机号格式有误")
    private String mobile;

    @Column(name = "fpno")
    @ApiModelProperty(value = "固定电话")
    private String tel;

    @Column(name = "fxno")
    @ApiModelProperty(value = "传真")
    private String fax;

    @Column(name = "wxno")
    @ApiModelProperty(value = "微信")
    private String wx;

    @Column(name = "qqno")
    @ApiModelProperty(value = "QQ")
    @Pattern(regexp = "[1-9][0-9]{4,}", message = "QQ号码不正确")
    private String qq;

    @Column(name = "mail")
    @ApiModelProperty(value = "邮箱")
    @Pattern(regexp = "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?", message = "邮箱格式不对")
    private String mail;

    @Column(name = "addr")
    @ApiModelProperty(value = "地址")
    private String addr;

    @Column(name = "onli")
    @ApiModelProperty(value = "是否在线", allowableValues = "0,1")
    private Short online;

    @Column(name = "SD$WKGP_CODE")
    @ApiModelProperty(value = "工作组编码")
    private String workgroupCode;

    @Column(name = "SD$WKGP_WKGP")
    @ApiModelProperty(value = "工作组")
    private String workgroup;

    @Column(name = "SD$URTP_CODE")
    @ApiModelProperty(value = "用户类型编码")
    private String sdUrtpCode;

    @Column(name = "SD$URTP_URTP")
    @ApiModelProperty(value = "用户类型")
    private String userType;

    @Column(name = "SD$NATN_CODE")
    @ApiModelProperty(value = "国家编码")
    private String nationCode;

    @Column(name = "SD$NATN_NATN")
    @ApiModelProperty(value = "国家")
    private String nation;

    @Column(name = "SD$PROV_CODE")
    @ApiModelProperty(value = "省份编码")
    private String provCode;

    @Column(name = "SD$PROV_PROV")
    @ApiModelProperty(value = "省份")
    private String prov;

    @Column(name = "SD$CITY_CODE")
    @ApiModelProperty(value = "城市编码")
    private String cityCode;

    @Column(name = "SD$CITY_CITY")
    @ApiModelProperty(value = "城市")
    private String city;

    @Column(name = "SD$TOWN_CODE")
    @ApiModelProperty(value = "乡镇编码")
    private String townCode;

    @Column(name = "SD$TOWN_TOWN")
    @ApiModelProperty(value = "乡镇")
    private String town;

    @Transient
    @ApiModelProperty(value = "用户角色列表", hidden = true)
    private List<Role> roles;

    @Transient
    @ApiModelProperty(value = "部门信息", hidden = true)
    private Dept dept;
}
